Document view: consistent view mode switch UX, better wrapping sidebar#607
Draft
Document view: consistent view mode switch UX, better wrapping sidebar#607
Conversation
58d21dc to
58f0b99
Compare
Rewrite PageViewerOrFallback as a view orchestrator that renders different content based on the active view mode (Combined, Text, OCR, Preview, Table) with a shared PreviewSwitcher footer toolbar. - Add Combined button to PreviewSwitcher when document has pages - Always land on Combined view for paged documents, overriding any view param carried from search URLs - Pin footer toolbar to bottom of viewport with scrollable content area - Remove the standalone 'View as Text' button from DocumentMetadata since the PreviewSwitcher now provides access to all view modes
Apply the same dark background (previewDark) to the paged document viewer wrapper so that all view modes (Combined, Text, OCR, Preview) have a consistent appearance and the footer toolbar does not appear visually detached from the content area.
- Allow action buttons to wrap within the sidebar by adding flex-wrap and gap to btn-group, preventing overflow cropping - Remove white-space: nowrap from resource breadcrumb segments so location paths can use the full sidebar width - Increase breadcrumb segment truncation threshold from 15 to 26 characters to show more useful path information
58f0b99 to
919d7ee
Compare
Remove the block in buildLink that propagated urlParams.view into generated links. The view param is document-specific (e.g. text, ocr, preview) and should not carry forward when navigating between pages. Previously this caused search result links to include the current view mode, so clicking a result while on an OCR view would land the next document on OCR instead of letting it choose its own default. View state is managed through Redux and the PreviewSwitcher component which sets an appropriate default when a document loads, so URL-based propagation is no longer needed. Also simplify the useEffect in PageViewerOrFallback to only set the combined view when no view is set, and include view in the dependency array (removing the eslint suppression). On refresh the user's chosen view is preserved since it remains in Redux.
The PreviewSwitcher previously always labelled the preview tab 'Preview', which is misleading for audio and video files. The resource's mimeTypes are already available in the component, so we now derive the label from them: 'Video' for video/* types, 'Audio' for audio/* types, and 'Preview' as the default for PDFs, images, etc. The label logic is extracted into a pure exported function (previewLabelForMimeTypes) with a colocated test covering video, audio, non-media, and mixed mime type scenarios.
This was referenced Mar 14, 2026
dee3143 to
ec9a951
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Probably best not to look at this until #606 is merged, because removing the "View as Text" button will make that problem worse.
Previously, documents with pages (PDFs) used the
PageViewer(Combined view) but had no way to switch to other views (e.g. Text, OCR, Preview) without navigating to the old viewer. The "View as Text" button in the sidebar opened a separate tab and had no return journey.This PR rewrites
PageViewerOrFallbackas a view orchestrator that renders aPreviewSwitchertoolbar at the bottom of the viewport, giving access to all available views (Combined, Text, OCR, Preview, Table) in a single unified interface. This makes the UI consistent with all documents that don't have pages.I think it still deserves to be called "PageViewerOrFallback" because we still fall back to the old views if for some reason we have earlier failed to generate pages.
So now...
?view=ocr.englishparameter. (Search probably shouldn't make document rendering decisions anyway, but that question deserves deeper consideration. And I didn't want to mess with the backend for this PR.)white-space: nowrap)Before (1) – in combined viewer mode
Before (2) – after user clicks on View as text button
After
Issue with searches proposing the wrong view mode
The
buildLinkutility previously carried theviewURL param into all generated links. This meant clicking a search result while viewing a document in OCR mode would land the next document on OCR too. Theviewparam is document-specific and should not propagate — view state is managed through Redux andPreviewSwitcher, which sets an appropriate default when each document loads. Refreshing the page now preserves the user's chosen view rather than resetting to a different view to the one the user had open.This change in particular probably deserves some proper testing effort.
Files changed
PageViewerOrFallback.tsx— rewritten as view orchestrator with Redux connectionbuildLink.js– no longer specifies the view mode; instead letsPageViewerOrFallbackdecide.PreviewSwitcher.js— added Combined button andtotalPagesprop; changes Preview button if audio or videoDocumentMetadata.js— removed "View as Text" button_buttons.scss— flex-wrap and gap on btn-group_resource-browser.scss— removed nowrap on breadcrumb segmentsResourceTrail.tsx— increased truncation thresholdNew file
PreviewSwitcher.spec.ts— tests for button naming based on mimetypeTesting
Not covered by this PR: